SET XACT_ABORT OFF
SET ARITHABORT OFF
/* DECLARE GLOBAL VARIABLES */
DECLARE @rptPK int
DECLARE @rptGroupPK int
DECLARE @tempPK int
DECLARE @errorcount int
DECLARE @dsql varchar(8000)
DECLARE @version decimal(9,2)
SELECT @version = CAST(REPLACE(LOWER(schema_version), 'sp', '') AS decimal(9,2)) FROM _schema
/* =====================================================
UPDATE REPORTS STYLES AND GROUP HEADERS - (ASListByCL_RC_870)
===================================================== */
IF @version >= 3.0
BEGIN
EXEC('PRINT ''Version 3.0 or greater detected. Importing Report Styles and Group Headers''
DECLARE @tempPK int
IF NOT EXISTS(SELECT ReportStyleName FROM ReportStyle WHERE ReportStyleName = ''Default'')
BEGIN
INSERT INTO ReportStyle (ReportStyleName, ReportStyleDesc, ReportStyleCSS, IsDefault, IsBase, RowVersionIPAddress, RowVersionUserPK, RowVersionInitials, RowVersionAction, RowVersionDate) VALUES(''Default'', null, ''.pageselect{FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Arial}
.heading {background-color:#ffffff; CURSOR:HAND; FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: royalblue; FONT-FAMILY: Arial; z-index: 2500;}
.legendHeader {FONT-WEIGHT: bold; FONT-SIZE: 14px; COLOR: #333333; FONT-FAMILY: Arial}
.normaltext {FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial}
.labels {FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: royalblue; FONT-FAMILY: Arial}
.assetUP {FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: green; FONT-FAMILY: Arial}
.assetDOWN {FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #DD0000; FONT-FAMILY: Arial}
.asset {FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: Arial}
.data {FONT-SIZE: 12px; COLOR: #494949; FONT-FAMILY: Arial}
.data_underline {BORDER-RIGHT: medium none; BORDER-TOP: medium none; FONT-SIZE: 12px; BORDER-LEFT: medium none; COLOR: #494949; BORDER-BOTTOM: #333333 1px solid; FONT-FAMILY: Arial}
.bottomline {BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: #333333 1px solid}
.buttons {FONT-SIZE: 12px; WIDTH: 80px; CURSOR: hand; COLOR: #333333; FONT-FAMILY: Arial}
.subtotal {BORDER-RIGHT: medium none; BORDER-TOP: #C0C0C0 1px solid; FONT-SIZE: 12px; BORDER-LEFT: medium none; COLOR: #333333; BORDER-BOTTOM: medium none; FONT-FAMILY: Arial}
.bodyclasspreview {padding:15; scrollbar-base-color: #EAEAEA;}
.bodyclasspreviewinwo {padding-right:15px; scrollbar-base-color: #EAEAEA;}
.bodyclassprint {PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px}
.bodyclassemail {PADDING-RIGHT: 15px; PADDING-LEFT: 15px; PADDING-BOTTOM: 20px; PADDING-TOP: 0px}
.group1 {padding-left:0; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial; FONT-WEIGHT: Bold; BACKGROUND-COLOR: #acc5e7}
.group2 {padding-left:10; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial; FONT-WEIGHT: Bold; BACKGROUND-COLOR: #c7d7ed}
.group3 {padding-left:20; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial; FONT-WEIGHT: Bold; BACKGROUND-COLOR: #dce8f4}
.group4 {padding-left:30; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial; FONT-WEIGHT: Bold; BACKGROUND-COLOR: #ecf1fb}
.group5 {padding-left:40; FONT-SIZE: 12px; COLOR: royalblue; FONT-FAMILY: Arial; FONT-WEIGHT: Bold; BACKGROUND-COLOR: #ffffff}
.groupheader {FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial; FONT-WEIGHT: Bold;}
.normalright {BORDER-RIGHT: #c0c0c0 1px solid; BORDER-TOP: #c0c0c0 1px solid; PADDING-LEFT: 1px; FONT-WEIGHT: normal; FONT-SIZE: 8pt; MARGIN-BOTTOM: 1px; BORDER-LEFT: #c0c0c0 1px solid; COLOR: #000000; BORDER-BOTTOM: #c0c0c0 1px solid; FONT-FAMILY: Arial; BACKGROUND-COLOR: #ffffff; TEXT-ALIGN: right}
TD.clsBtnUp {cursor: hand; color: black; font-weight: normal; border: outset #FFFFFF 2px;}
TD.clsBtnDown {cursor: hand; color: black; font-weight: normal; border: inset #FFFFFF 2px;}
TD.clsBtnOn {cursor: hand; color: black; font-weight: normal; border: inset #FFFFFF 2px;}
TD.clsBtnOff {color: black; font-weight: normal; tab-index: 0; padding-top: 2px; padding-left: 2px; padding-right: 2px; padding-bottom: 2px; border: ;}
INPUT {padding-left:3;}
A:link {FONT-SIZE: 8pt; CURSOR: hand; COLOR: #315aad; FONT-FAMILY: Arial; BACKGROUND-COLOR: transparent;}
A:visited {FONT-SIZE: 8pt; CURSOR: hand; COLOR: #315aad; FONT-FAMILY: Arial; BACKGROUND-COLOR: transparent;}
A:active {FONT-SIZE: 8pt; CURSOR: hand; COLOR: #315aad; FONT-FAMILY: Arial; BACKGROUND-COLOR: transparent;}
A:hover {COLOR: red;}
fieldset {border:1 solid gray;}
.buttonsdisabled { display: static; filter: Gray() Alpha(Opacity=40); cursor:; }
.buttonsenabled { display: ; filter: none; cursor:hand; }
.normalrow {FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial }
.tb {width:100%; PADDING-LEFT: 1px; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial; border:1 solid gray;}
.tbf {BACKGROUND-COLOR: #ffffcc; width:100%; PADDING-LEFT: 1px; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial; border:1 solid gray;}
.ta {width:200px; PADDING-LEFT: 1px; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial; border:1 solid gray;}
.taf {BACKGROUND-COLOR: #ffffcc; width:200px; PADDING-LEFT: 1px; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial; border:1 solid gray;}
.cb {COLOR: #333333;}
.HeaderRight {font-family:Arial;font-size:16px;color:#333333;font-weight:bold}
.SubHeaderRight {font-family:Arial;font-size:11px;font-weight:normal}
.SRInstructions {margin-top:5px;font-family:Arial;font-size:8pt;color:green;font-weight:bold}
.verticalcolumn {border:1 solid #CCCCCC;}
.mcpagebreak {page-break-before: always;}
.ReportRow1 {background-color:#FFFFFF; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial }
.ReportRow2 {background-color:#EFEFEF; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial }
.ReportRowCrit1 {background-color:#FFFFFF; FONT-SIZE: 8pt; COLOR: #333333; FONT-FAMILY: Arial }
.ReportRowCrit2 {background-color:#EFEFEF; FONT-SIZE: 8pt; COLOR: #333333; FONT-FAMILY: Arial }
.SmartRow {background-color:#FFDF84; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial; cursor:hand; }
.SubReportRow {background-color:#DEEFC6; FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: Arial }'', 0, 1, '''', '''', ''_MC'', '''', getdate())
END
')
END
/* ============================================================
ReportID: ASListByCL_RC_870
Report Name: Mean Time Between Failures - By Asset
============================================================ */
IF EXISTS (
SELECT ReportName FROM Reports WITH (NOLOCK)
WHERE ReportID = 'ASListByCL_RC_870')
BEGIN
PRINT '*******************************************************'
PRINT 'Report Exists - Updating...'
PRINT 'Report: Mean Time Between Failures - By Asset'
PRINT '*******************************************************'
/* ================================================
UPDATE REPORT RECORDS - (ASListByCL_RC_870)
================================================ */
/* Set ReportPK for this Report */
SELECT @rptPK = ReportPK FROM Reports WITH (NOLOCK) WHERE ReportID='ASListByCL_RC_870'
/* Update Main Report Fields */
UPDATE Reports
SET [ReportIDPriorToCopy]='ASListByCL', [ReportDesc]=null, [Sort1]='Asset.ClassificationName', [Sort2]='Asset.AssetID', [Sort3]=null, [Sort4]=null, [Sort5]=null, [Sort1DESC]=0, [Sort2DESC]=0, [Sort3DESC]=0, [Sort4DESC]=0, [Sort5DESC]=0, [Group1]=1, [Group2]=0, [Group3]=0, [Group4]=0, [Group5]=0, [Header1]=0, [Header2]=0, [Header3]=0, [Header4]=0, [Header5]=0, [GroupHeader1]=null, [GroupHeader2]=null, [GroupHeader3]=null, [GroupHeader4]=null, [GroupHeader5]=null, [Total1]=0, [Total2]=0, [Total3]=0, [Total4]=0, [Total5]=0, [Chart]=null, [ChartName]='Location', [ChartField]='AUTO_SORT1', [ChartSize]='L', [ReportFile]='rpt_generic1.asp', [FromSQL]='FROM Asset', [JoinSQL]='INNER JOIN AssetHierarchy ON AssetHierarchy.AssetPK = Asset.AssetPK', [WhereSQL]=null, [GroupBy]=0, [hits]=9, [Sequence]=0, [Layout]='hor', [VertCols]=1, [PageBreakEachRecord]=0, [Custom]=0, [ReportCopy]=1, [MCRegistrationDB]=0, [PrintCriteria]=1, [Active]=1, [UDFChar1]=null, [UDFChar2]=null, [UDFChar3]=null, [UDFChar4]=null, [UDFChar5]=null, [UDFDate1]=null, [UDFDate2]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionAction]='EDIT', [RowVersionDate]=getdate() , [ChartFunction]=null, [ChartFunctionField]=null, [NoDetail]=0, [PB1]=0, [PB2]=0, [PB3]=0, [PB4]=0, [PB5]=0, [SLDefault]=1, [SLType]=' ', [SLAction]='PW', [SLModuleID]=' ', [SLPKField]=null, [SLReportID]=null, [SLCustomAction]=null, [SLTooltip]=null, [SDDisplay]=' ', [SDModuleID]=' ', [SDPKField]=null, [SmartEmail]=0, [ChartPosition]=null, [ChartFormat]='I', [ChartSQL]=null, [Chart2]=null, [ChartName2]=null, [ChartField2]=null, [ChartSize2]=null, [ChartFormat2]=null, [ChartFunction2]=null, [ChartFunctionField2]=null, [ChartPosition2]=null, [ChartSQL2]=null, [Chart3]=null, [ChartName3]=null, [ChartField3]=null, [ChartSize3]=null, [ChartFormat3]=null, [ChartFunction3]=null, [ChartFunctionField3]=null, [ChartPosition3]=null, [ChartSQL3]=null, [ChartOnly]=0, [NoHeader]=0, [SRID1]=null, [SRPKField1]=null, [SRID2]=null, [SRPKField2]=null, [SRID3]=null, [SRPKField3]=null, [SRID4]=null, [SRPKField4]=null, [SRID5]=null, [SRPKField5]=null, [ReportPageSize]='Default', [ReportWidth]='100%', [PhotoCriteria]=1, [ReportStyleName]='Default', [UsedFor]='REPORTS', [SmartEmailLaborPK]=0, [SCDefault]='H', [SCField1]=null, [SCField2]=null, [SCField3]=null, [ReportStyleFontSize]=null, [ReportStyleFontColor]=null, [ReportStyleFontFamily]=null
WHERE ReportPK = @rptPK
IF (@@error > 0) SET @errorcount = @errorcount + 1
IF @version >= 3.0
BEGIN
SET @dSQL = 'UPDATE Reports SET [HavingSQL]=null, [DisplayPivotBar]=0, [DisplayColumnLines]=1, [DisplayTitleonPageBreak]=0, [DisplayFormatCriteria]=1, [R1T]=''N'', [R1O]=''BETWEEN '', [R1V1]=1, [R1V2]=10, [R1A]=8, [R1L]=0, [R1F]=12, [R1CS]=''border: #FF0000 2px solid; background-color: #FFE1E1;'', [R1AF]=''C'', [R2T]=''N'', [R2O]=''GREATERTHAN '', [R2V1]=50, [R2V2]=null, [R2A]=8, [R2L]=0, [R2F]=-1, [R2CS]=''color:#c0c0c0;'', [R2AF]=''C'', [R3T]='' '', [R3O]=null, [R3V1]=null, [R3V2]=null, [R3A]=0, [R3L]=0, [R3F]=0, [R3CS]=''border: #0066CC 2px solid;'', [R3AF]=''C'' WHERE ReportPK = ' + CAST(@rptPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF @version >= 4.2
BEGIN
SET @dSQL = 'UPDATE Reports SET [DisplayDescription]=0 WHERE ReportPK = ' + CAST(@rptPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
PRINT 'Updating Report - ASListByCL_RC_870'
/* ==================================================
DELETE AND INSERT REPORT GROUPS - (ASListByCL_RC_870)
=================================================== */
DELETE FROM Report_ReportGroup WHERE ReportPK = @rptPK
PRINT 'Deleting Report_ReportGroup Rows - ASListByCL_RC_870'
IF (@@error > 0) SET @errorcount = @errorcount + 1
/* ==================================================
DELETE AND INSERT REPORT TABLES - (ASListByCL_RC_870)
=================================================== */
DELETE FROM ReportTables WHERE ReportPK = @rptPK
PRINT 'Deleting ReportTables Rows - ASListByCL_RC_870'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportTables ([ReportPK], [RFTable], [Alias], [DisplayOrder], [LabelOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', null, 0, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportTables Row - Asset'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportTables ([ReportPK], [RFTable], [Alias], [DisplayOrder], [LabelOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'AssetHierarchy', null, 0, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportTables Row - AssetHierarchy'
IF (@@error > 0) SET @errorcount = @errorcount + 1
/* ==================================================
UPDATE OR INSERT REPORT CRITERIA - (ASListByCL_RC_870)
=================================================== */
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'Type')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='Type', [CritName]=null, [Operator]='is', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=2, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'Type'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.Type'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'Type', 'Asset', 'Type', 'A', null, 'is', 0, 1, null, 2, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.Type'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'AccountID')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='AccountPK', [CritName]=null, [Operator]='is', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=5, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'AccountID'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.AccountPK'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'AccountID', 'Asset', 'AccountPK', null, null, 'is', 0, 1, null, 5, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.AccountPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'AssetID')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='AssetPK', [CritName]=null, [Operator]='is', [isMulti]=0, [AskLater]=1, [LabelOverride]='Location / Asset', [DisplayOrder]=0, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'AssetID'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.AssetPK'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'AssetID', 'Asset', 'AssetPK', null, null, 'is', 0, 1, 'Location / Asset', 0, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.AssetPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'ClassificationID')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='ClassificationPK', [CritName]='Boiler', [Operator]='is', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=1, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'ClassificationID'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.ClassificationPK'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'ClassificationID', 'Asset', 'ClassificationPK', null, 'Boiler', 'is', 0, 1, null, 1, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.ClassificationPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'RepairCenterID')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='RepairCenterPK', [CritName]=null, [Operator]='is', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=9, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'RepairCenterID'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.RepairCenterPK'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'RepairCenterID', 'Asset', 'RepairCenterPK', null, null, 'is', 0, 1, null, 9, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.RepairCenterPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'ShopID')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='ShopPK', [CritName]=null, [Operator]='is', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=8, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'ShopID'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.ShopPK'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'ShopID', 'Asset', 'ShopPK', null, null, 'is', 0, 1, null, 8, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.ShopPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'Serial')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='Serial', [CritName]=null, [Operator]='is', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=3, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'Serial'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.Serial'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'Serial', 'Asset', 'Serial', null, null, 'is', 0, 1, null, 3, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.Serial'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'WarrantyExpire')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='WarrantyExpire', [CritName]=null, [Operator]='is within', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=6, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'WarrantyExpire'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.WarrantyExpire'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'WarrantyExpire', 'Asset', 'WarrantyExpire', null, null, 'is within', 0, 1, null, 6, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.WarrantyExpire'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'LastMaintained')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='LastMaintained', [CritName]=null, [Operator]='is within', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=7, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'LastMaintained'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.LastMaintained'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'LastMaintained', 'Asset', 'LastMaintained', null, null, 'is within', 0, 1, null, 7, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.LastMaintained'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'ManufacturerID')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='ManufacturerPK', [CritName]=null, [Operator]='is', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=11, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'ManufacturerID'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.ManufacturerPK'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'ManufacturerID', 'Asset', 'ManufacturerPK', null, null, 'is', 0, 1, null, 11, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.ManufacturerPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'Model')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='Model', [CritName]=null, [Operator]='is', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=4, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'Model'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.Model'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'Model', 'Asset', 'Model', null, null, 'is', 0, 1, null, 4, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.Model'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'Vicinity')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='Vicinity', [CritName]=null, [Operator]='is', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=10, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'Vicinity'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.Vicinity'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'Vicinity', 'Asset', 'Vicinity', null, null, 'is', 0, 1, null, 10, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.Vicinity'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportCriteriaPK FROM ReportCriteria WITH (NOLOCK) WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'PurchasedDate')
BEGIN
UPDATE ReportCriteria
SET [SQLWhereTable]='Asset', [SQLWhereField]='PurchasedDate', [CritName]=null, [Operator]='is within', [isMulti]=0, [AskLater]=1, [LabelOverride]=null, [DisplayOrder]=12, [FK_LookupOverride]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate()
WHERE ReportPK = @rptPK AND DisplayTable = 'Asset' AND DisplayField = 'PurchasedDate'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportCriteria Row - Asset.PurchasedDate'
END
ELSE
BEGIN
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'PurchasedDate', 'Asset', 'PurchasedDate', null, null, 'is within', 0, 1, null, 12, null, null, null, 0, '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.PurchasedDate'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
/* ==================================================
UPDATE OR INSERT REPORT FIELDS - (ASListByCL_RC_870)
=================================================== */
IF EXISTS (
SELECT ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'AssetName')
BEGIN
SELECT @tempPK = ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'AssetName'
UPDATE ReportFields
SET [ReportPK]=@rptPK, [DataDictPK]=2108, [AGFunction]=null, [Alias]=null, [DisplayOrder]=1, [Display]=1, [NotUserSelectable]=0, [LabelOverride]=null, [TotalIfSelected]=0, [BlankLineIfSelected]=0, [UseCustomExpression]=0, [CustomExpression]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate(), [SLAction]=null, [SLModuleID]=null, [SLPKField]=null, [SLReportID]=null, [SLCustomAction]=null, [SLToolTip]=null
WHERE [ReportPK]=@rptPK AND [RFTable]='Asset' AND [RFField]='AssetName'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportFields Row - Asset.AssetName'
END
ELSE
BEGIN
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 2108, null, 'Asset', 'AssetName', null, 1, 1, 0, null, 0, 0, 0, null, null, '', '', '_MC', getdate(), null, null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.AssetName'
IF (@@error > 0)
BEGIN
SET @errorcount = @errorcount + 1
SET @tempPK = -1
END
ELSE
BEGIN
SET @tempPK = @@IDENTITY
END
END
IF @version >= 4.2
BEGIN
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = null, [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = null, [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'AssetID')
BEGIN
SELECT @tempPK = ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'AssetID'
UPDATE ReportFields
SET [ReportPK]=@rptPK, [DataDictPK]=2107, [AGFunction]=null, [Alias]=null, [DisplayOrder]=0, [Display]=1, [NotUserSelectable]=0, [LabelOverride]=null, [TotalIfSelected]=0, [BlankLineIfSelected]=0, [UseCustomExpression]=0, [CustomExpression]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate(), [SLAction]=null, [SLModuleID]=null, [SLPKField]=null, [SLReportID]=null, [SLCustomAction]=null, [SLToolTip]=null
WHERE [ReportPK]=@rptPK AND [RFTable]='Asset' AND [RFField]='AssetID'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportFields Row - Asset.AssetID'
END
ELSE
BEGIN
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 2107, null, 'Asset', 'AssetID', null, 0, 1, 0, null, 0, 0, 0, null, null, '', '', '_MC', getdate(), null, null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.AssetID'
IF (@@error > 0)
BEGIN
SET @errorcount = @errorcount + 1
SET @tempPK = -1
END
ELSE
BEGIN
SET @tempPK = @@IDENTITY
END
END
IF @version >= 4.2
BEGIN
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = null, [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = null, [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'LastMaintained')
BEGIN
SELECT @tempPK = ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'LastMaintained'
UPDATE ReportFields
SET [ReportPK]=@rptPK, [DataDictPK]=2422, [AGFunction]=null, [Alias]=null, [DisplayOrder]=5, [Display]=1, [NotUserSelectable]=0, [LabelOverride]='Last Corrective
Maintenance WO
Complete Date', [TotalIfSelected]=0, [BlankLineIfSelected]=0, [UseCustomExpression]=1, [CustomExpression]='(select max(WO.Complete) from WO with (nolock) where WO.AssetPK = Asset.AssetPK and WO.IsGenerated = 0 and WO.Complete is not null)', [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate(), [SLAction]=' ', [SLModuleID]=null, [SLPKField]=null, [SLReportID]=null, [SLCustomAction]=null, [SLToolTip]=null
WHERE [ReportPK]=@rptPK AND [RFTable]='Asset' AND [RFField]='LastMaintained'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportFields Row - Asset.LastMaintained'
END
ELSE
BEGIN
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 2422, null, 'Asset', 'LastMaintained', null, 5, 1, 0, 'Last Corrective
Maintenance WO
Complete Date', 0, 0, 1, '(select max(WO.Complete) from WO with (nolock) where WO.AssetPK = Asset.AssetPK and WO.IsGenerated = 0 and WO.Complete is not null)', null, '', '', '_MC', getdate(), ' ', null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.LastMaintained'
IF (@@error > 0)
BEGIN
SET @errorcount = @errorcount + 1
SET @tempPK = -1
END
ELSE
BEGIN
SET @tempPK = @@IDENTITY
END
END
IF @version >= 4.2
BEGIN
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = '' '', [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = ''datetime2'', [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'Longitude')
BEGIN
SELECT @tempPK = ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'Longitude'
UPDATE ReportFields
SET [ReportPK]=@rptPK, [DataDictPK]=8708, [AGFunction]=null, [Alias]=null, [DisplayOrder]=6, [Display]=1, [NotUserSelectable]=0, [LabelOverride]='Count of
Corrective WOs', [TotalIfSelected]=0, [BlankLineIfSelected]=0, [UseCustomExpression]=1, [CustomExpression]='(Select Count(WO.WOPK) from WO with (nolock) where WO.AssetPK = Asset.AssetPK and WO.IsGenerated = 0)', [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate(), [SLAction]=' ', [SLModuleID]=null, [SLPKField]=null, [SLReportID]=null, [SLCustomAction]=null, [SLToolTip]=null
WHERE [ReportPK]=@rptPK AND [RFTable]='Asset' AND [RFField]='Longitude'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportFields Row - Asset.Longitude'
END
ELSE
BEGIN
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 8708, null, 'Asset', 'Longitude', null, 6, 1, 0, 'Count of
Corrective WOs', 0, 0, 1, '(Select Count(WO.WOPK) from WO with (nolock) where WO.AssetPK = Asset.AssetPK and WO.IsGenerated = 0)', null, '', '', '_MC', getdate(), ' ', null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.Longitude'
IF (@@error > 0)
BEGIN
SET @errorcount = @errorcount + 1
SET @tempPK = -1
END
ELSE
BEGIN
SET @tempPK = @@IDENTITY
END
END
IF @version >= 4.2
BEGIN
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = '' '', [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = ''numeric'', [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'RiskFactor5')
BEGIN
SELECT @tempPK = ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'RiskFactor5'
UPDATE ReportFields
SET [ReportPK]=@rptPK, [DataDictPK]=6849, [AGFunction]=null, [Alias]=null, [DisplayOrder]=7, [Display]=1, [NotUserSelectable]=0, [LabelOverride]='Mean Time
Between Failure
(in Days)', [TotalIfSelected]=0, [BlankLineIfSelected]=0, [UseCustomExpression]=1, [CustomExpression]='dbo.MCCSTM_MeanTimeBetweenFailures(Asset.AssetPK)', [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate(), [SLAction]=' ', [SLModuleID]=null, [SLPKField]=null, [SLReportID]=null, [SLCustomAction]=null, [SLToolTip]=null
WHERE [ReportPK]=@rptPK AND [RFTable]='Asset' AND [RFField]='RiskFactor5'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportFields Row - Asset.RiskFactor5'
END
ELSE
BEGIN
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 6849, null, 'Asset', 'RiskFactor5', null, 7, 1, 0, 'Mean Time
Between Failure
(in Days)', 0, 0, 1, 'dbo.MCCSTM_MeanTimeBetweenFailures(Asset.AssetPK)', null, '', '', '_MC', getdate(), ' ', null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.RiskFactor5'
IF (@@error > 0)
BEGIN
SET @errorcount = @errorcount + 1
SET @tempPK = -1
END
ELSE
BEGIN
SET @tempPK = @@IDENTITY
END
END
IF @version >= 4.2
BEGIN
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = '' '', [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = ''numeric'', [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'ManufacturerName')
BEGIN
SELECT @tempPK = ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'ManufacturerName'
UPDATE ReportFields
SET [ReportPK]=@rptPK, [DataDictPK]=2425, [AGFunction]=null, [Alias]=null, [DisplayOrder]=2, [Display]=1, [NotUserSelectable]=0, [LabelOverride]=null, [TotalIfSelected]=0, [BlankLineIfSelected]=0, [UseCustomExpression]=0, [CustomExpression]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate(), [SLAction]=null, [SLModuleID]=null, [SLPKField]=null, [SLReportID]=null, [SLCustomAction]=null, [SLToolTip]=null
WHERE [ReportPK]=@rptPK AND [RFTable]='Asset' AND [RFField]='ManufacturerName'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportFields Row - Asset.ManufacturerName'
END
ELSE
BEGIN
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 2425, null, 'Asset', 'ManufacturerName', null, 2, 1, 0, null, 0, 0, 0, null, null, '', '', '_MC', getdate(), null, null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.ManufacturerName'
IF (@@error > 0)
BEGIN
SET @errorcount = @errorcount + 1
SET @tempPK = -1
END
ELSE
BEGIN
SET @tempPK = @@IDENTITY
END
END
IF @version >= 4.2
BEGIN
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = null, [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = null, [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'Model')
BEGIN
SELECT @tempPK = ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'Model'
UPDATE ReportFields
SET [ReportPK]=@rptPK, [DataDictPK]=3678, [AGFunction]=null, [Alias]=null, [DisplayOrder]=3, [Display]=1, [NotUserSelectable]=0, [LabelOverride]=null, [TotalIfSelected]=0, [BlankLineIfSelected]=0, [UseCustomExpression]=0, [CustomExpression]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate(), [SLAction]=null, [SLModuleID]=null, [SLPKField]=null, [SLReportID]=null, [SLCustomAction]=null, [SLToolTip]=null
WHERE [ReportPK]=@rptPK AND [RFTable]='Asset' AND [RFField]='Model'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportFields Row - Asset.Model'
END
ELSE
BEGIN
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 3678, null, 'Asset', 'Model', null, 3, 1, 0, null, 0, 0, 0, null, null, '', '', '_MC', getdate(), null, null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.Model'
IF (@@error > 0)
BEGIN
SET @errorcount = @errorcount + 1
SET @tempPK = -1
END
ELSE
BEGIN
SET @tempPK = @@IDENTITY
END
END
IF @version >= 4.2
BEGIN
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = null, [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = null, [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF EXISTS (
SELECT ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'Serial')
BEGIN
SELECT @tempPK = ReportFieldPK FROM ReportFields WITH (NOLOCK) WHERE ReportPK = @rptPK AND RFTable = 'Asset' AND RFField = 'Serial'
UPDATE ReportFields
SET [ReportPK]=@rptPK, [DataDictPK]=3679, [AGFunction]=null, [Alias]=null, [DisplayOrder]=4, [Display]=1, [NotUserSelectable]=0, [LabelOverride]=null, [TotalIfSelected]=0, [BlankLineIfSelected]=0, [UseCustomExpression]=0, [CustomExpression]=null, [DemoLaborPK]=null, [RowVersionIPAddress]='', [RowVersionUserPK]='', [RowVersionInitials]='_MC', [RowVersionDate]=getdate(), [SLAction]=null, [SLModuleID]=null, [SLPKField]=null, [SLReportID]=null, [SLCustomAction]=null, [SLToolTip]=null
WHERE [ReportPK]=@rptPK AND [RFTable]='Asset' AND [RFField]='Serial'
IF (@@error > 0) SET @errorcount = @errorcount + 1
PRINT 'Updating ReportFields Row - Asset.Serial'
END
ELSE
BEGIN
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 3679, null, 'Asset', 'Serial', null, 4, 1, 0, null, 0, 0, 0, null, null, '', '', '_MC', getdate(), null, null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.Serial'
IF (@@error > 0)
BEGIN
SET @errorcount = @errorcount + 1
SET @tempPK = -1
END
ELSE
BEGIN
SET @tempPK = @@IDENTITY
END
END
IF @version >= 4.2
BEGIN
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = null, [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = null, [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
/* =====================================================
UPDATE REPORTS COLS IN DATA DICT - (ASListByCL_RC_870)
===================================================== */
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'AssetID'
PRINT 'Updating DataDict Row - Asset.AssetID'
IF (@@error > 0) SET @errorcount = @errorcount + 1
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'AssetName'
PRINT 'Updating DataDict Row - Asset.AssetName'
IF (@@error > 0) SET @errorcount = @errorcount + 1
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'LastMaintained'
PRINT 'Updating DataDict Row - Asset.LastMaintained'
IF (@@error > 0) SET @errorcount = @errorcount + 1
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'ManufacturerName'
PRINT 'Updating DataDict Row - Asset.ManufacturerName'
IF (@@error > 0) SET @errorcount = @errorcount + 1
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'Model'
PRINT 'Updating DataDict Row - Asset.Model'
IF (@@error > 0) SET @errorcount = @errorcount + 1
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'Serial'
PRINT 'Updating DataDict Row - Asset.Serial'
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
/* REPORT DID NOT EXIST, CREATE ALL RECORDS */
ELSE
BEGIN
PRINT '*******************************************************'
PRINT 'Report Does Not Exist - Inserting...'
PRINT 'Report: Mean Time Between Failures - By Asset'
PRINT '*******************************************************'
/* =====================================================
INSERT REPORT RECORDS - (ASListByCL_RC_870)
===================================================== */
/* INSERT Main Report */
INSERT INTO Reports ([ReportIDPriorToCopy], [ReportID], [ReportName], [ReportDesc], [RepairCenterPK], [Sort1], [Sort2], [Sort3], [Sort4], [Sort5], [Sort1DESC], [Sort2DESC], [Sort3DESC], [Sort4DESC], [Sort5DESC], [Group1], [Group2], [Group3], [Group4], [Group5], [Header1], [Header2], [Header3], [Header4], [Header5], [GroupHeader1], [GroupHeader2], [GroupHeader3], [GroupHeader4], [GroupHeader5], [Total1], [Total2], [Total3], [Total4], [Total5], [Chart], [ChartName], [ChartField], [ChartSize], [ReportFile], [FromSQL], [JoinSQL], [WhereSQL], [GroupBy], [hits], [Sequence], [Layout], [VertCols], [PageBreakEachRecord], [Custom], [ReportCopy], [MCRegistrationDB], [PrintCriteria], [Active], [UDFChar1], [UDFChar2], [UDFChar3], [UDFChar4], [UDFChar5], [UDFDate1], [UDFDate2], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionAction], [RowVersionDate], [ChartFunction], [ChartFunctionField], [NoDetail], [PB1], [PB2], [PB3], [PB4], [PB5], [SLDefault], [SLType], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip], [SDDisplay], [SDModuleID], [SDPKField], [SmartEmail], [ChartPosition], [ChartFormat], [ChartSQL], [Chart2], [ChartName2], [ChartField2], [ChartSize2], [ChartFormat2], [ChartFunction2], [ChartFunctionField2], [ChartPosition2], [ChartSQL2], [Chart3], [ChartName3], [ChartField3], [ChartSize3], [ChartFormat3], [ChartFunction3], [ChartFunctionField3], [ChartPosition3], [ChartSQL3], [ChartOnly], [NoHeader], [HavingSQL], [SRID1], [SRPKField1], [SRID2], [SRPKField2], [SRID3], [SRPKField3], [SRID4], [SRPKField4], [SRID5], [SRPKField5], [ReportPageSize], [ReportWidth], [PhotoCriteria], [ReportStyleName], [UsedFor], [SmartEmailLaborPK], [SCDefault], [SCField1], [SCField2], [SCField3], [ReportStyleFontSize], [ReportStyleFontColor], [ReportStyleFontFamily] )
VALUES('ASListByCL', 'ASListByCL_RC_870', 'Mean Time Between Failures - By Asset', null, null, 'Asset.ClassificationName', 'Asset.AssetID', null, null, null, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, null, null, null, null, 0, 0, 0, 0, 0, null, 'Location', 'AUTO_SORT1', 'L', 'rpt_generic1.asp', 'FROM Asset', 'INNER JOIN AssetHierarchy ON AssetHierarchy.AssetPK = Asset.AssetPK', null, 0, 0, 0, 'hor', 1, 0, 0, 1, 0, 1, 1, null, null, null, null, null, null, null, null, '', '', '_MC', 'CREATE', getdate(), null, null, 0, 0, 0, 0, 0, 0, 1, ' ', 'PW', ' ', null, null, null, null, ' ', ' ', null, 0, null, 'I', null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0, 0, null, null, null, null, null, null, null, null, null, null, null, 'Default', '100%', 1, 'Default', 'REPORTS', 0, 'H', null, null, null, null, null, null)
PRINT 'Inserting Report - ASListByCL_RC_870'
IF (@@error > 0) SET @errorcount = @errorcount + 1
SET @rptPK = @@Identity
IF @version >= 3.0
BEGIN
SET @dSQL = 'UPDATE Reports SET [HavingSQL]=null, [DisplayPivotBar]=0, [DisplayColumnLines]=1, [DisplayTitleonPageBreak]=0, [DisplayFormatCriteria]=1, [R1T]=''N'', [R1O]=''BETWEEN '', [R1V1]=1, [R1V2]=10, [R1A]=8, [R1L]=0, [R1F]=12, [R1CS]=''border: #FF0000 2px solid; background-color: #FFE1E1;'', [R1AF]=''C'', [R2T]=''N'', [R2O]=''GREATERTHAN '', [R2V1]=50, [R2V2]=null, [R2A]=8, [R2L]=0, [R2F]=-1, [R2CS]=''color:#c0c0c0;'', [R2AF]=''C'', [R3T]='' '', [R3O]=null, [R3V1]=null, [R3V2]=null, [R3A]=0, [R3L]=0, [R3F]=0, [R3CS]=''border: #0066CC 2px solid;'', [R3AF]=''C'' WHERE ReportPK = ' + CAST(@rptPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
IF @version >= 4.2
BEGIN
SET @dSQL = 'UPDATE Reports SET [DisplayDescription]=0 WHERE ReportPK = ' + CAST(@rptPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
/* ==================================================
UPDATE OR INSERT REPORT GROUPS - (ASListByCL_RC_870)
=================================================== */
/* ==================================================
INSERT REPORT TABLES- (ASListByCL_RC_870)
=================================================== */
INSERT INTO ReportTables ([ReportPK], [RFTable], [Alias], [DisplayOrder], [LabelOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', null, 0, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportTables Row - Asset'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportTables ([ReportPK], [RFTable], [Alias], [DisplayOrder], [LabelOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'AssetHierarchy', null, 0, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportTables Row - AssetHierarchy'
IF (@@error > 0) SET @errorcount = @errorcount + 1
/* ==================================================
INSERT REPORT CRITERIA - (ASListByCL_RC_870)
=================================================== */
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'Type', 'Asset', 'Type', 'A', null, 'is', 0, 1, null, 2, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.Type'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'AccountID', 'Asset', 'AccountPK', null, null, 'is', 0, 1, null, 5, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.AccountPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'AssetID', 'Asset', 'AssetPK', null, null, 'is', 0, 1, 'Location / Asset', 0, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.AssetPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'ClassificationID', 'Asset', 'ClassificationPK', null, 'Boiler', 'is', 0, 1, null, 1, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.ClassificationPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'RepairCenterID', 'Asset', 'RepairCenterPK', null, null, 'is', 0, 1, null, 9, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.RepairCenterPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'ShopID', 'Asset', 'ShopPK', null, null, 'is', 0, 1, null, 8, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.ShopPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'Serial', 'Asset', 'Serial', null, null, 'is', 0, 1, null, 3, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.Serial'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'WarrantyExpire', 'Asset', 'WarrantyExpire', null, null, 'is within', 0, 1, null, 6, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.WarrantyExpire'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'LastMaintained', 'Asset', 'LastMaintained', null, null, 'is within', 0, 1, null, 7, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.LastMaintained'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'ManufacturerID', 'Asset', 'ManufacturerPK', null, null, 'is', 0, 1, null, 11, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.ManufacturerPK'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'Model', 'Asset', 'Model', null, null, 'is', 0, 1, null, 4, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.Model'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'Vicinity', 'Asset', 'Vicinity', null, null, 'is', 0, 1, null, 10, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.Vicinity'
IF (@@error > 0) SET @errorcount = @errorcount + 1
INSERT INTO ReportCriteria ([ReportPK], [DisplayTable], [DisplayField], [SQLWhereTable], [SQLWhereField], [DefaultCritValue], [CritName], [Operator], [isMulti], [AskLater], [LabelOverride], [DisplayOrder], [FK_LookupOverride], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate]) VALUES (@rptPK, 'Asset', 'PurchasedDate', 'Asset', 'PurchasedDate', null, null, 'is within', 0, 1, null, 12, null, null, '', '', '_MC', getdate())
PRINT 'Inserting ReportCriteria Row - Asset.PurchasedDate'
IF (@@error > 0) SET @errorcount = @errorcount + 1
/* ==================================================
INSERT REPORT FIELDS - (ASListByCL_RC_870)
=================================================== */
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 2108, null, 'Asset', 'AssetName', null, 1, 1, 0, null, 0, 0, 0, null, null, '', '', '_MC', getdate(), null, null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.AssetName'
IF (@@error > 0) SET @errorcount = @errorcount + 1
IF @version >= 4.2
BEGIN
SET @tempPK = @@IDENTITY
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = null, [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = null, [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 2107, null, 'Asset', 'AssetID', null, 0, 1, 0, null, 0, 0, 0, null, null, '', '', '_MC', getdate(), null, null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.AssetID'
IF (@@error > 0) SET @errorcount = @errorcount + 1
IF @version >= 4.2
BEGIN
SET @tempPK = @@IDENTITY
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = null, [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = null, [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 2422, null, 'Asset', 'LastMaintained', null, 5, 1, 0, 'Last Corrective
Maintenance WO
Complete Date', 0, 0, 1, '(select max(WO.Complete) from WO with (nolock) where WO.AssetPK = Asset.AssetPK and WO.IsGenerated = 0 and WO.Complete is not null)', null, '', '', '_MC', getdate(), ' ', null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.LastMaintained'
IF (@@error > 0) SET @errorcount = @errorcount + 1
IF @version >= 4.2
BEGIN
SET @tempPK = @@IDENTITY
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = '' '', [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = ''datetime2'', [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 8708, null, 'Asset', 'Longitude', null, 6, 1, 0, 'Count of
Corrective WOs', 0, 0, 1, '(Select Count(WO.WOPK) from WO with (nolock) where WO.AssetPK = Asset.AssetPK and WO.IsGenerated = 0)', null, '', '', '_MC', getdate(), ' ', null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.Longitude'
IF (@@error > 0) SET @errorcount = @errorcount + 1
IF @version >= 4.2
BEGIN
SET @tempPK = @@IDENTITY
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = '' '', [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = ''numeric'', [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 6849, null, 'Asset', 'RiskFactor5', null, 7, 1, 0, 'Mean Time
Between Failure
(in Days)', 0, 0, 1, 'dbo.MCCSTM_MeanTimeBetweenFailures(Asset.AssetPK)', null, '', '', '_MC', getdate(), ' ', null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.RiskFactor5'
IF (@@error > 0) SET @errorcount = @errorcount + 1
IF @version >= 4.2
BEGIN
SET @tempPK = @@IDENTITY
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = '' '', [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = ''numeric'', [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 2425, null, 'Asset', 'ManufacturerName', null, 2, 1, 0, null, 0, 0, 0, null, null, '', '', '_MC', getdate(), null, null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.ManufacturerName'
IF (@@error > 0) SET @errorcount = @errorcount + 1
IF @version >= 4.2
BEGIN
SET @tempPK = @@IDENTITY
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = null, [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = null, [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 3678, null, 'Asset', 'Model', null, 3, 1, 0, null, 0, 0, 0, null, null, '', '', '_MC', getdate(), null, null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.Model'
IF (@@error > 0) SET @errorcount = @errorcount + 1
IF @version >= 4.2
BEGIN
SET @tempPK = @@IDENTITY
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = null, [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = null, [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
INSERT INTO ReportFields ([ReportPK], [DataDictPK], [AGFunction], [RFTable], [RFField], [Alias], [DisplayOrder], [Display], [NotUserSelectable], [LabelOverride], [TotalIfSelected], [BlankLineIfSelected], [UseCustomExpression], [CustomExpression], [DemoLaborPK], [RowVersionIPAddress], [RowVersionUserPK], [RowVersionInitials], [RowVersionDate], [SLAction], [SLModuleID], [SLPKField], [SLReportID], [SLCustomAction], [SLTooltip])
VALUES(@rptPK, 3679, null, 'Asset', 'Serial', null, 4, 1, 0, null, 0, 0, 0, null, null, '', '', '_MC', getdate(), null, null, null, null, null, null)
PRINT 'Inserting ReportFields Row - Asset.Serial'
IF (@@error > 0) SET @errorcount = @errorcount + 1
IF @version >= 4.2
BEGIN
SET @tempPK = @@IDENTITY
SET @dSQL = 'UPDATE ReportFields SET [Alignment] = null, [AdditionalWidth] = null, [PivotSetup] = null, [AddPivotColumnsWithNoDataFrom] = null, [AddPivotColumnsWithNoDataFromCustom] = null, [Data_Type_Override] = null, [ColumnFormat] = null, [ColumnCS] = null, [GroupByCustomExpression] = 1 WHERE ReportFieldPK = ' + CAST(@tempPK AS varchar(20)) + '
'
EXEC(@dSQL)
IF (@@error > 0) SET @errorcount = @errorcount + 1
END
/* =====================================================
UPDATE REPORTS COLS IN DATA DICT - (ASListByCL_RC_870)
===================================================== */
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'AssetID'
PRINT 'Updating DataDict Row - Asset.AssetID'
if (@@error > 0) Set @errorcount = @errorcount + 1
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'AssetName'
PRINT 'Updating DataDict Row - Asset.AssetName'
if (@@error > 0) Set @errorcount = @errorcount + 1
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'LastMaintained'
PRINT 'Updating DataDict Row - Asset.LastMaintained'
if (@@error > 0) Set @errorcount = @errorcount + 1
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'ManufacturerName'
PRINT 'Updating DataDict Row - Asset.ManufacturerName'
if (@@error > 0) Set @errorcount = @errorcount + 1
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'Model'
PRINT 'Updating DataDict Row - Asset.Model'
if (@@error > 0) Set @errorcount = @errorcount + 1
UPDATE DataDict
SET [REPORT_NOSELECT]=null, [REPORT_EDIT]='TB', [REPORT_LABEL]=null, [TOTALIFSELECTED]=0
WHERE TABLE_NAME = 'Asset' AND COLUMN_NAME = 'Serial'
PRINT 'Updating DataDict Row - Asset.Serial'
if (@@error > 0) Set @errorcount = @errorcount + 1
END
PRINT '*******************************************************'
IF (@errorcount > 0) PRINT @errorcount + ' Error(s) Occurred: ASListByCL_RC_870'
ELSE PRINT 'No Errors Occurred: ASListByCL_RC_870'